//将一个正整数分解质因数。例如：输入90,打印出90=2*3*3*5。 
import scala.io.StdIn

object PrimeFactorization {
  def main(args: Array[String]): Unit = {
    println("请输入一个正整数:")
    val num = StdIn.readInt()
    if (num <= 0) {
      println("输入的数必须是正整数。")
    } else {
      val factors = factorize(num)
      val result = if (factors.size == 1) {
        s"$num=${factors.head}"
      } else {
        s"$num=${factors.mkString("*")}"
      }
      println(result)
    }
  }

  def factorize(n: Int): List[Int] = {
    var num = n
    var divisor = 2
    var factors = List.empty[Int]

    while (num > 1) {
      if (num % divisor == 0) {
        factors = factors :+ divisor
        num /= divisor
      } else {
        divisor += 1
      }
    }
    factors
  }
}